<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <p> for 循环里面的 return，会直接退出整个循环，并且以后的代码不会执行</p>
  <p> for(var i), 循环外是访问不到的</p>
  <script>

    function show(n) {
      for(var i=0; i< 100; i++) {
        console.log('run'+i);
        if(i ==n){
          return true
        }
      }
      return false
    }
    console.log(show(9));
    // console.log('i---', i);
    
    let arr = [1,2,3,4,5,6]
    arr.forEach(item => {
      console.log('25',item);
      if(item == 2){
        return false
      }
    })
    console.log('-30-',arr.indexOf(40))
    let arr2 = [
      {name: 1},
      {name: 2},
      {name: 3},
    ]
    let n = arr2.findIndex((item, index) => {
      return item.name == 30
    })
    console.log('n', n);

    // map 测试 深拷贝

    let arr3 = [
      {
        name: 3
      },
      {
        name: 5
      }
    ]
    let arr4 = arr3.map(item => item)
    arr3[0].name = 66
    console.log('arr4', arr4);
  </script>
</body>
</html>